package com.yyx.app1.CommonControls.MyViewPager;

import android.app.Activity;
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yyx.app1.MyApp;
import com.yyx.app1.R;
import com.yyx.app1.tool.ImageTool;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by yuexing on 2015/10/13.
 */
@EViewGroup(R.layout.button_back)
public class BackButton extends LinearLayout {
    private Context context;
    @ViewById
    ImageView image;

    @ViewById
    TextView text;

    @ViewById
    LinearLayout line;

    public BackButton(Context context) {
        super(context);
        this.context = context;
    }

    public BackButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
    }

    public BackButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    @AfterViews
    public void init()
    {
        try {
            setImage();
        }
        catch (Exception e)
        {
            Log.e("异常1510281345", e.toString());
        }
    }

    public ImageView getImage() {
        return image;
    }

    public void setImage() {
        image.setImageBitmap(((MyApp)((Activity)context).getApplication()).getBaseDataManager().getResDrawable(
                R.drawable.back, ImageTool.dip2px(context,30), ImageTool.dip2px(context, 50)));
    }

    public TextView getText() {
        return text;
    }

    public void setText(TextView text) {
        this.text = text;
    }

    public void SetStyle()
    {
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ImageTool.dip2px(context,30),ImageTool.dip2px(context,30));
        layoutParams.gravity = Gravity.CENTER;
        image.setLayoutParams(layoutParams);
        image.setPadding(0,0,ImageTool.dip2px(context,3),0);
    }
}
